#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define PRECISION  

void system_invoke(void)
{
  double d = 4.2305;
  char pstr[16] = {0};
  double result = 0.0;

  sprintf(pstr, "%.1f\n", d);	// 4.2
  printf("%s\n", pstr);			// space
  printf("%f\n", atof(pstr));	// 4.200000

  result = atof(pstr) + 0.1;
  printf("result = %f\n", result);	// 4.300000
}

void d_div(void)
{
  double dl = 4.2305;
  int a = 0;
  int b = 0;

  a = ((int) (dl * 10)) % 10;
  b = ((int) (dl * 100)) % 10;
  printf("a = %d b = %d \n", a, b);	// a = 2 b = 3
}

double d_accuracy(double x)
{
  int i_accur;
  double d_accur;

  i_accur = (int) x;
  d_accur = x - i_accur;  /* decimal place */

  //  if (d_accuracy < (double)0.05) {}

  return d_accur;
}

int main(void)
{
  printf("%lf\n", d_accuracy(4.230));	// 0.230000
  
  system_invoke();
  d_div();

  return 0;
}


